﻿using Microsoft.CSharp.Activities;
using System;
using System.Activities;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WFExtended.Twitter.Activities.Designers;

namespace WFExtended.Twitter.Activities
{
    /// <summary>
    /// Returns the lists the specified user has been added to.
    /// </summary>
    [ToolboxBitmapAttribute(typeof(EntryPoint), "Resources.ListToolbox.bmp")]
    [Designer(typeof(ListDesigner))]
    [Description("Returns the lists the specified user has been added to.")]
    public class GetMembershipsLists : TwitterOperationInvoker<Lists>
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="GetMembershipsLists"/> class.
        /// </summary>
        public GetMembershipsLists()
            : base("GetMembershipsLists")
        {
            Cursor = new InArgument<long>(new CSharpValue<long>("-1"));
        }

        /// <summary>
        /// The screen name of the user for whom to return results for.
        /// </summary>
        /// <value>
        /// The username.
        /// </value>
        [Browsable(true)]
        [Category("Properties")]
        [Description("The screen name of the user for whom to return results for.")]
        [RequiredArgument]
        public InArgument<string> Username { get; set; }

        /// <summary>
        /// Breaks the results into pages.
        /// </summary>
        /// <value>
        /// The cursor.
        /// </value>
        [Browsable(true)]
        [Category("Properties")]
        [Description("Breaks the results into pages.")]
        [RequiredArgument]
        public InArgument<long> Cursor { get; set; }


        /// <summary>
        /// Caches the metadata.
        /// </summary>
        /// <param name="metadata">The metadata.</param>
        protected override void CacheMetadata(System.Activities.NativeActivityMetadata metadata)
        {
            RuntimeArgument usernameArgument = new RuntimeArgument("Username", typeof(string), ArgumentDirection.In, true);
            metadata.Bind(Username, usernameArgument);
            metadata.AddArgument(usernameArgument);

            RuntimeArgument cursorArgument = new RuntimeArgument("Cursor", typeof(long), ArgumentDirection.In, true);
            metadata.Bind(Cursor, cursorArgument);
            metadata.AddArgument(cursorArgument);

            base.CacheMetadata(metadata);
        }

        /// <summary>
        /// Executes the specified context.
        /// </summary>
        /// <param name="context">The context.</param>
        protected override void Execute(System.Activities.NativeActivityContext context)
        {
            Parameters.Clear();

            Parameters.Add("username", Username);
            Parameters.Add("cursor", Cursor);

            base.Execute(context);
        }
    }
}
